﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infusion.CRM.WF.CRM40WSX.CurrencySvc;

namespace Infusion.CRM.WF.CRM40WSX.Proxy
{
    public class CurrencyProxy
    {
        public double Convert(Currency from, Currency to)
        {
            if (from == to)
            {
                return 1.0;
            }
            else
            {
                return new CurrencyConvertor().ConversionRate(from, to);
            }
        }

        public double Convert(string from, string to)
        {
            Currency from2 = (Currency)Enum.Parse(typeof(Currency), from);
            Currency to2 = (Currency)Enum.Parse(typeof(Currency), to);
            return Convert(from2, to2);
        }

        public double Convert(double value, Currency from, Currency to)
        {
            return value * Convert(from, to);
        }

        public double Convert(double value, string from, string to)
        {
            Currency from2 = (Currency)Enum.Parse(typeof(Currency), from);
            Currency to2 = (Currency)Enum.Parse(typeof(Currency), to);
            return value * Convert(from2, to2);
        }
    }
}
